<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../vue@3.2.23.js"></script>
	</head>
	<body>
		<div id="app">
			<div class="count">
				父组件的计数器：{{count}}
				<counter :count="count" @count-add="countAdd"></counter>
			</div>
		</div>
	</body>
</html>
<script>
	const app = Vue.createApp({
		data() {
			return{
				count:20
			}
		},
		methods:{
			countAdd(){
				this.count +=1
			}
		}
	});
	app.component('counter',{
		props:['count'],
		methods:{
			changeCount(){
				this.$emit('count-add')
			}
		},
		template:
		`
		<div class="count">
			子组件的计数器：{{count}}
			
		</div>
		`
	})
	const vm = app.mount("#app")
</script>